#include "stdafx.h"
#include "InputDevice.h"


CInputDevice::CInputDevice()
{

}

CInputDevice::~CInputDevice()
{
	assert(m_listeners.empty());
}

void CInputDevice::RegisterListener(IInputListener* listener)
{
	assert(listener);

	bool success = stl::push_back_unique(m_listeners, listener);
	assert(success);
}

void CInputDevice::UnregisterListener(IInputListener* listener)
{
	assert(listener);

	bool success = stl::find_and_remove(m_listeners, listener);
	assert(success);
}

void CInputDevice::NotifyEvent(const SInputEvent& input_event)
{
	for (uint i = 0; i < m_listeners.size(); ++i)
	{
		IInputListener* listener = m_listeners[i];
		listener->OnInputEvent(input_event);
	}
}